



# #python当中的元组
# #遍历、索引切片、与列表进行相互转换
# tuple1 = ('mysql','sqlserver','oracle','sqlite','postgresql','db2','ocean base')   #关系型数据库
# tuple2 = ('redis','mongodb','memcached')                      #非关系型数据库
# #遍历
# for i in tuple1:
#     print(i)
# #索引切片
# print("tuple2中的最后一个元素：",tuple2[-1])
# print("tuple1中的第四个元素：",tuple1[3])
# #与列表进行相互转换
# tuple1=list(tuple1)
# tuple1[0] = 'mariadb'
# tuple1=tuple(tuple1)
# print(tuple1)
'''
tuple1 = ("Math",'English','chemistry','biology','physics')
for i in tuple1:
    print(i)
print(tuple1[-3])
print(tuple1[::2])
'''
# #判断长度
# print(len("hello world"))
# #判断总和
# print(sum([1,2,3,4,5,6,7,8,9,10]))
# print(max([1,2,3,4,5,6,7,8,9,10]))
# print(min([1,2,3,4,5,6,7,8,9,10]))
# #删除某个变量，或列表中的某个元素
# a = [1,2,3,4,5]
# #del a #删除整个列表
# del a[0] #删除列表中的某个元素
# print(a)
'''
tuple2=[1,2,3,4,5,6,7,87,98,78]
print(len(tuple2))
print(max(tuple2))
print(min(tuple2))
print(sum(tuple2))
del tuple2[6]
print(tuple2)
'''
#python 中的集合
#定义空集合使用set()
# a = {1,4,6,3,6,8,3,5,7,1,1,2,2}
# print(a)  #集合会自动去重

# #列表去重
# a = [1,4,6,3,6,8,3,5,7,1,1,2,2]
# b = []
# for r in a:
#     if r not in b:
#         b.append(r)
# print(b)

set1 = {'mysql','sqlserver','oracle','sqlite','postgresql','db2','ocean base'}
set2 = {'redis','mongodb','memcached','oracle','sqlite','postgresql','db2'}
#差集
print(set1 - set2)
print(set2 - set1)
#并集
print(set1 | set2)
#交集
print(set1 & set2)
#对称差集  去掉交集的部分
print(set1 ^ set2) 

# #Python集合操作
# set2 = {'redis','mongodb','memcached','oracle','sqlite','postgresql','db2'}
# set2.add("linux")
# print(set2)
# set2.discard('db2')
# print(set2)
# set2.remove("sqlite")
# print(set2)
# set3 = {1,2,3,4,5,6}
# set3.pop()  #删除
# set3.pop()
# set3.pop()
# print(set3)
# set2.update([1,2,3,4,5])
# print(set2)

# #python中的字典
# #定义
# dict1={"姓名":"张三","年龄":18,"性别":"男","爱好":["篮球","足球","排球"]}
# #给字典添加键值对
# dict1['工作']='工人'
# print(dict1)
# #删除字典中的元素
# del dict1['爱好']
# print(dict1)
# #修改字典中的数据
# dict1['年龄']=20
# print(dict1)


# info = ["姓名","性别","年龄","工作"]
# dict2 = {}.fromkeys(info,"未填写")   #fromkeys初始化字典
# print(dict2)

# #获取字典中的值
# dict1={"姓名":"张三","年龄":18,"性别":"男","爱好":["篮球","足球","排球"]}
# print(dict1["姓名"])
# print(dict1.get("姓名"))
# #print(dict1["工资"])
# print(dict1.get("工资","未找到该信息"))
# #get  是查找，如果没有返回默认值，
# print(dict1.setdefault("工资","未找到该信息"))  
# #setdefault  是查找，如果没有则返回默认值并在原字典中设置对应的键值对
# print(dict1)

#遍历字典
# for i in dict1.values():   #遍历字典中的值
#     print(i)
# for i in dict1.items():    #遍历字典中的键值对
#     print(i)
# for i in dict1.keys():       #遍历字典中的键
#     print(i)

# #给字典增加元素
# dict1={"姓名":"张三","年龄":18,"性别":"男","爱好":["篮球","足球","排球"]}
# dict1.update({"a":'c',"b":"d"})
# print(dict1)

